﻿namespace KinonekoSoftware.Foundation.Languages
{
    public class FileLanguageProvider : LanguageProvider
    {
        internal FileLanguageProvider(string folderName) => FolderName = folderName;
        
        
        public override IReadOnlyList<string> GetUnformattedLines(LanguageArea language)
        {
            var fileName = Path.Combine(FolderName, GetDefaultFileName(language));
            return File.ReadAllLines(fileName);
        }

        public static FileLanguageProvider CreateFromThisDomain()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Languages");
            return new FileLanguageProvider(path);
        }
        
        public static FileLanguageProvider CreateFromThisDomain(string subFolder)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, subFolder);
            return new FileLanguageProvider(path);
        }
        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="folderName"></param>
        /// <returns></returns>
        public static FileLanguageProvider Create(string folderName)
        {
            return new FileLanguageProvider(folderName);
        }
        
        public string FolderName { get; }
    }
}